<?php
class Indicadores_Form_Crearindicador extends Form_Base{
	
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function init() {
		$this->setName('indicador');
		$this->setMethod("post");
		$this->setAttrib('enctype', 'multipart/form-data');
		$domConfig = Zend_Registry::get('domConfig'); //esto se crea en el bootstrap
		
		$array_elements[] = new Zend_Form_Element_Hidden("codindicador");
		
		$element = new Zend_Form_Element_Textarea('idindicador');
		$element->setLabel('ID - Identificador  :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",2);
        $array_elements[] = $element;
		
		$element = new Zend_Form_Element_Textarea('nombreindicador');
		$element->setLabel('Nombre :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",2);
        $array_elements[] = $element;

		$element = new Zend_Form_Element_Textarea('descripcion');
		$element->setLabel('Descripción :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
		$element->setAttrib("rows",2);
		$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
		$array_elements[] = $element;
		
		$element = new Zend_Form_Element_Select('periodicidad');
		$element->setLabel ( 'Periodicidad: ' );
		$element->setRegisterInArrayValidator(false);
		$element->setMultiOptions($domConfig->PERIODICIDAD->toArray());
		$element->setValue(1);
        $array_elements[]=$element;
        
        
        $Variables = new Variables_Model_Variables();
        $datos_unidades = $Variables->getUnidades();
        
        $array_unidades = array();
        foreach ($datos_unidades as $value) {
            $array_unidades[$value["codunidad"]] = $value["nombreunidad"];
        }
        
		$element = new Zend_Form_Element_Select('codunidad');
		$element->setLabel ( 'Unidad : ' );
		$element->setRegisterInArrayValidator(false);
		$element->setMultiOptions($array_unidades);
		$element->setValue(4);
        $array_elements[]=$element;
        
        $element = new Zend_Form_Element_Text("valormalo");
        $element->setLabel("Valor no deseado: ");
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
        $element->addValidator('digits');
        $element->setAttrib("size", 7);
        $array_elements[] = $element;

        $element = new Zend_Form_Element_Text("valoroptimo");
        $element->setLabel("Valor óptimo: ");
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
        $element->addValidator('digits');
        $element->setAttrib("size", 7);
        $array_elements[] = $element;
        
        $element = new Zend_Form_Element_Text("valorexcelente");
        $element->setLabel("Valor excelente: ");
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
        $element->addValidator('digits');
        $element->setAttrib("size", 7);
        $array_elements[] = $element;
        		
        $element = new App_Form_Element_Datepicker('fechaactualiza');
		$element->setLabel('Fecha de actualización : ');
		$element->setAttrib("readonly","readonly");
		$array_elements[] = $element;
		
		$element = new Zend_Form_Element_Submit ( 'btnSubmit' );
		$element->setValue('Guardar');
		$element->setLabel("Guardar");
		$element->setAttrib("class", "iceCmdBtn");
		$array_elements[] = $element;
		
		$this->addElements ($array_elements);
		
		$this->loadTableDecorators();
	}
	
}